import re
from typing import Dict


class Skill(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["绝学名称"] = self.__match(r"(?<=\|)绝学名称=(.*?)(?=\n)")
        self["绝学类别"] = self.__match(r"(?<=\|)绝学类别=(.*?)(?=\n)")
        self["绝学冷却"] = self.__match(r"(?<=\|)绝学冷却=(.*?)(?=\n)")
        self["绝学消耗"] = self.__match(r"(?<=\|)绝学消耗=(.*?)(?=\n)")
        self["绝学射程"] = self.__match(r"(?<=\|)绝学射程=(.*?)(?=\n)")
        self["绝学范围"] = self.__match(r"(?<=\|)绝学范围=(.*?)(?=\n)")
        self["绝学描述"] = self.__match(r"(?<=\|)绝学描述=(.*?)(?=\n)")

    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""
